package com.valuegroup.smarttodo.data.enums;

public enum HabitSetRepeatEnum {

    EVERYDAY("everyday", "每天", 0),
    WORKDAY("workday", "每个工作日", 1),
    WEEKLY("weekly", "每周", 2),
    MONTHLY("monthly", "每月", 3),
    YEARLY("yearly", "每年", 4),
    EFFECTIVE_DATE("effective_date", "有效期", 5),
    TYPE("type", "重复类型", 6),
    UNWORKDAY("unworkday", "每个工作日", 7);

    private String key;
    private String title;
    private int position;

    HabitSetRepeatEnum(String key, String title, int position) {
        this.key = key;
        this.title = title;
        this.position = position;
    }

    public static String getPageTitleForPosition(int position) {
        for (HabitSetRepeatEnum e : HabitSetRepeatEnum.values()) {
            if (e.position == position) {
                return e.getTitle();
            }
        }
        return "";
    }

    public static String getKeyForPosition(int position) {
        for (HabitSetRepeatEnum e : HabitSetRepeatEnum.values()) {
            if (e.position == position) {
                return e.getKey();
            }
        }
        return "";
    }

    public static HabitSetRepeatEnum getEnumForPosition(int position) {
        for (HabitSetRepeatEnum e : HabitSetRepeatEnum.values()) {
            if (e.position == position) {
                return e;
            }
        }
        return HabitSetRepeatEnum.MONTHLY;
    }

    public String getKey() {
        return key;
    }

    public String getTitle() {
        return title;
    }

    public int getPosition() {
        return position;
    }
}
